﻿using furion.blog.Domain.IRepositories;
using furion.blog.Domain.MySQL;
using Furion.DependencyInjection;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace furion.blog.EntityFramework.Core.Repositories
{
    public class MenuRepository : BaseSqlSugarRepository<Menu>, IMenuRepository, ISingleton
    {
        public readonly ISqlSugarClient _db;

        public MenuRepository(ISqlSugarClient db) {
            this._db = db;
        }

        public async Task<List<Menu>> All() {
            return await base.GetListAsync();
        }


        /// <summary>
        /// 清空表数据
        /// </summary>
        /// <returns></returns>
        public void Truncate()
        {
            this._db.DbMaintenance.TruncateTable<Menu>();
        }

        /// <summary>
        /// 批量保存
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task Save(List<Menu> data) {
            await base.InsertRangeAsync(data);
        }

    }
}
